﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace OplugAbpProject.Migrations
{
    public partial class CreateMerchant : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Merchant",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    TenantId = table.Column<int>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    SysRowID = table.Column<string>(nullable: true),
                    MerchName = table.Column<string>(maxLength: 50, nullable: false),
                    Address = table.Column<string>(maxLength: 500, nullable: true),
                    Community = table.Column<string>(maxLength: 500, nullable: true),
                    City = table.Column<string>(maxLength: 20, nullable: true),
                    Province = table.Column<string>(maxLength: 20, nullable: true),
                    Country = table.Column<string>(maxLength: 20, nullable: true),
                    Contractor = table.Column<string>(maxLength: 50, nullable: true),
                    BusinessLicenseNo = table.Column<string>(maxLength: 50, nullable: true),
                    BusinessScope = table.Column<string>(maxLength: 50, nullable: true),
                    BuildingStructure = table.Column<string>(maxLength: 50, nullable: true),
                    Telphone = table.Column<string>(maxLength: 50, nullable: true),
                    Areas = table.Column<decimal>(maxLength: 50, nullable: false),
                    LandOwner = table.Column<string>(maxLength: 50, nullable: true),
                    HouseOwner = table.Column<string>(maxLength: 50, nullable: true),
                    PosX = table.Column<decimal>(nullable: true),
                    PosY = table.Column<decimal>(nullable: true),
                    CommentText = table.Column<string>(type: "text", nullable: true),
                    CategoryId = table.Column<int>(nullable: false),
                    CategoryName = table.Column<string>(maxLength: 50, nullable: true),
                    isActive = table.Column<bool>(nullable: false),
                    isRec = table.Column<bool>(nullable: false),
                    Stars = table.Column<int>(nullable: false),
                    Staus = table.Column<string>(maxLength: 8, nullable: true),
                    PictureURL = table.Column<string>(maxLength: 500, nullable: true),
                    Logo = table.Column<string>(maxLength: 500, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Merchant", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MerchantEvents",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    TenantId = table.Column<int>(nullable: false),
                    MerchId = table.Column<long>(nullable: false),
                    MerchSysRowID = table.Column<string>(maxLength: 50, nullable: true),
                    EventType = table.Column<string>(maxLength: 20, nullable: true),
                    EventContent = table.Column<string>(type: "text", nullable: true),
                    ProblemText = table.Column<string>(type: "text", nullable: true),
                    PictureURL = table.Column<string>(maxLength: 500, nullable: true),
                    VedioURL = table.Column<string>(maxLength: 500, nullable: true),
                    Rectification = table.Column<bool>(nullable: false),
                    EventStatus = table.Column<string>(maxLength: 8, nullable: true),
                    LastInspector = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MerchantEvents", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MerchSaftyInfo",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    TenantId = table.Column<int>(nullable: false),
                    MerchId = table.Column<long>(nullable: false),
                    MerchSysRowID = table.Column<string>(maxLength: 50, nullable: true),
                    MainCharger = table.Column<string>(maxLength: 50, nullable: true),
                    Chargeer = table.Column<string>(maxLength: 50, nullable: true),
                    Telphone = table.Column<string>(maxLength: 50, nullable: true),
                    IsTraining = table.Column<bool>(nullable: false),
                    PersonCount = table.Column<int>(nullable: false),
                    IsHazardousChemicals = table.Column<bool>(nullable: false),
                    UseGas = table.Column<bool>(nullable: false),
                    SafetyEequipment = table.Column<bool>(nullable: false),
                    SaftyGrade = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MerchSaftyInfo", x => x.Id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Merchant");

            migrationBuilder.DropTable(
                name: "MerchantEvents");

            migrationBuilder.DropTable(
                name: "MerchSaftyInfo");
        }
    }
}
